package com.walle.ak47.commons.jaxrs.interceptor.monitor;

import java.util.concurrent.atomic.AtomicLong;

public class Performance {
	private AtomicLong lessOneSecCount;
	private AtomicLong betweenOneAndThreeSecCount;
	private AtomicLong betweenThreeAndFiveSecCount;
	private AtomicLong betweenFiveAndTenSecCount;
	private AtomicLong betweenTenAndTwentySecCount;
	private AtomicLong moreThanTwentySecCount;
	
	public Performance() {
		this.lessOneSecCount = new AtomicLong();
		this.betweenOneAndThreeSecCount = new AtomicLong();
		this.betweenThreeAndFiveSecCount = new AtomicLong();
		this.betweenFiveAndTenSecCount = new AtomicLong();
		this.betweenTenAndTwentySecCount = new AtomicLong();
		this.moreThanTwentySecCount = new AtomicLong();
	}
	
	public void incr(long millsSec) {
		if (millsSec <= 1000) {
			this.lessOneSecCount.incrementAndGet();
		} else if (millsSec <= 3000) {
			this.betweenOneAndThreeSecCount.incrementAndGet();
		} else if (millsSec <= 5000) {
			this.betweenThreeAndFiveSecCount.incrementAndGet();
		} else if (millsSec <= 10000) {
			this.betweenFiveAndTenSecCount.incrementAndGet();
		} else if (millsSec <= 20000) {
			this.betweenTenAndTwentySecCount.incrementAndGet();
		} else {
			this.moreThanTwentySecCount.incrementAndGet();
		}
	}
	
	public AtomicLong getLessOneSecCount() {
		return lessOneSecCount;
	}
	public AtomicLong getBetweenOneAndThreeSecCount() {
		return betweenOneAndThreeSecCount;
	}
	public AtomicLong getBetweenThreeAndFiveSecCount() {
		return betweenThreeAndFiveSecCount;
	}
	public AtomicLong getBetweenFiveAndTenSecCount() {
		return betweenFiveAndTenSecCount;
	}
	public AtomicLong getBetweenTenAndTwentySecCount() {
		return betweenTenAndTwentySecCount;
	}
	public AtomicLong getMoreThanTwentySecCount() {
		return moreThanTwentySecCount;
	}
}
